{% extends 'layout.html' %}
{% load static %}
{% load permission %}

{% block content %}
    <div style="margin-bottom: 5px" class="clearfix">
{#    {% if role == 'ADMIN' %}#}
{#        <a href="{% url "policy_add" %}" class="btn btn-success"><span class="glyphicon glyphicon-plus-sign"></span>#}
{#            新建</a>#}
{#    {% endif %}#}
        {% add_permission request 'policy_add'  %}
    <form class="form-inline right" method="get">
        <div class="form-group">
            <label class="sr-only" for="exampleInputEmail3">Email address</label>
            <input type="text" name="keyword" class="form-control" id="exampleInputEmail3" placeholder="请输入需要查找的内容" value="{{ keyword }}">
        </div>
        <button type="submit" class="btn btn-default glyphicon glyphicon-search"></button>
    </form>
    </div>
    <table class="table table-bordered">
        <thead>
        <tr>
            <th>ID</th>
            <th>数量</th>
            <th>价格</th>
            {% if request|has_permission:"policy_edit,policy_delete" %}
            <th>操作</th>
            {% endif %}
        </tr>
        </thead>
        <tbody>
        {% for row in queryset %}
            <tr row-id="{{ row.id }}">
                <td>{{ row.id }}</td>
                <td>{{ row.count }}</td>
                <td>{{ row.price }}</td>
                {% if request|has_permission:"policy_edit,policy_delete" %}
                <td>
{#                    <a href="{% url 'policy_edit' pk=row.id %}" class="btn btn-primary btn-xs">编辑</a>#}
{#                    <a href="{% url 'policy_delete' %}" class="btn btn-danger btn-xs btn-lg btn_delete" cid="{{ row.id }}"  data-toggle="modal" data-target="#myModal">删除</a>#}
                    {% edit_permission request 'policy_edit' pk=row.id  %}
                    {% delete_permission request 'policy_delete' %}
                </td>
            {% endif %}
            </tr>
        {% endfor %}
        </tbody>
    </table>
{% include "include/deleteModel.html" %}
<nav aria-label="Page navigation">
  <ul class="pagination">
    {{ page_string }}
  </ul>
</nav>
{% endblock %}
{% block js %}
    <script src="{% static '/js/delete_model.js' %}"></script>
    <script>
        var DELETE_CID;
        var DELETE_URL = "{% url 'policy_delete' %}";
    </script>
{% endblock %}
